import 'package:dk_flutter_base/dk_core.dart';
import 'package:dk_flutter_base/dk_ui.dart';
import 'package:dk_flutter_module_sale/common/common_search/widget/widget_common_search_bar.dart';
import 'package:dk_flutter_module_sale/common/common_search/widget/widget_common_search_content.dart';
import 'package:dk_flutter_module_sale/common/config/page_base_common.dart';
import 'package:dk_flutter_module_sale/config/route/common_widget_route.dart';
import 'package:dk_flutter_module_sale/sale/sale_out/watch_plan/bean/bean_data_commonlist_config.dart';

@ARoute(url: CommonWidgetRoute.COMMON_SEARCH_LIST)
class CommonSearchPage extends CommonPage {
  final WidgetOption option;

  CommonSearchPage(this.option) : super();

  @override
  void onInitState(CommonPageBloc pageBloc) {
    SearchData searchData = SearchData.fromJson(option.widgetParams);
    pageBloc.switchPage(
      DkVisibilityCompose(
        VisibilityComposeOption.replaceWithOutSize(
          (BuildContext context) {
            return Scaffold(
              backgroundColor: Colors.white,
              appBar: PreferredSize(
                  child: CommonSearchBar(
                    pageBloc.eventBus,
                    initContent: "",
                    placeHolder: searchData.placeholder,
                    isShowCancel: true,
                  ),
                  preferredSize: Size.fromHeight(44)),
              body: CommonSearchContent(searchData, pageBloc.eventBus),
            );
          },
          (BuildContext context) {
            return Scaffold(
              appBar: DkAppBar(DKAppBarParams.withBackNoMenu(
                pageBloc.context,
                titleContent: "搜索界面",
              )),
              body: LogicPage(
                LogicParam.logicEmpty(
                  tip: "参数为null",
                  listener: () {
                    RouteUtil.pop(pageBloc.context);
                  },
                ),
              ),
            );
          },
          visible: objNotEmpty(option) && mapNotEmpty(option.widgetParams),
        ),
      ),
    );
  }
}
